package com.test.satokenmongodbdemo.security;

import cn.dev33.satoken.session.SaSession;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

@Document("saTokenMongo")
public class SaTokenMongoData {

    @Id
    private String id;

    @Indexed(unique = true)
    private String key;

    private SaSession session;

    private String string;

    // 根据 expireAt 字段配置过期时间
    // 详情见 https://github.com/spring-projects/spring-data-mongodb/issues/4844
    @SuppressWarnings("removal")
    @Indexed(expireAfterSeconds = 0)
    private LocalDateTime expireAt;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public SaSession getSession() {
        return session;
    }

    public void setSession(SaSession session) {
        this.session = session;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

    public LocalDateTime getExpireAt() {
        return expireAt;
    }

    public void setExpireAt(LocalDateTime expireAt) {
        this.expireAt = expireAt;
    }
}
